<%@ include file="../header.jsp" %>
<%@ page import="admin.*"%>
<%@ page import="admin.options.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%
	int password_length = (new PasswordLength()).getPasswordLength();

	UserBean user1 = (UserBean)request.getAttribute("user");
    if (user1==null)
		user1 = new User();

	RoleOptions rio = new RoleOptions();

	CostCenterOptions cco=  new CostCenterOptions();

	UserMultiRoleBean[] userMultiRoles = (UserMultiRoleBean[])request.getAttribute("userMultiRoles");
	String multiRoleId[] = null;
	if (userMultiRoles != null ) {
		multiRoleId = new String[userMultiRoles.length];
		for(int i = 0; i < userMultiRoles.length; i++)
			multiRoleId[i] = userMultiRoles[i].getRole_id();
	}
%>

<body>
<script language="javascript">
	function formValidation() {
		var d1 = fm.user_id;
		var d3 = fm.passwd;
		var d6 = fm.pass_exp_date;
		var d7 = fm.inactive_date;

		if( isNull(d1,"User ID") || isNull(d3,"Password")) {
			return false;
		}

if (fm.oldpasswd.value === fm.passwd.value ){
    alert("Not saved because same password!");
    return false;
}


//alert('userid not null and password no null');


		if (d6.value != "") {
			if (!validationDate(d6.value)) {
				alert("invalid Password Expiry Date!");
				return false;
			}
		}

//alert('inactive date = '+ (d7.value));

		if (d7.value != "") {
      		if (!validationDate(d7.value)) {
        		alert("invalid Inactive Date!");
				return false;
			}
		}
                
                

    	if(d3.value.length < <%=password_length%>) {
			alert("Password length cannot be less than "+<%=password_length%>);
			d3.focus();
			return false;
		}



		return true;
	}
</script>

<h2>User Maintenance</h2>
<form id="fm" method="post" action="<%=contextPath%>/servlet/admin.UserChangePwdServlet">
<table cols="10" border="0">
<tr>
	<td>User ID</td>
	<td>
            <%--
            <input type="text" name="user_id" value="<%=user1.getUser_id()%>" maxlength="10" <%=readOnly%> />
            --%>
            <span><%=user1.getUser_id()%></span>
        <input type="hidden" name="user_id" value="<%=user1.getUser_id()%>" />
        </td>
</tr>
<tr>
	<td>Password</td>
	<td>
	<input type="password" name="passwd" value="<%=user1.getPasswd()%>" maxlength="10"/>
	<input type="hidden" name="oldpasswd" value="<%=user1.getPasswd()%>"/>
	</td>
</tr>

<tr>
	<td>
            <%--
            Password Expiry Date (DD/MM/YYYY)
            --%>
        </td>
	<td>
<%--    
            <input type="text" name="pass_exp_date" value="<%=user1.getPass_exp_date()%>" maxlength="10">
--%>
            <input type="hidden" name="pass_exp_date" value="<%=user1.getPass_exp_date()%>" />

</td>
</tr>

<tr>
	<td><%--
Inactive Date(DD/MM/YYYY)
        --%>
</td>
	<td>
            <%--
		<input type="text" name="inactive_date" value="<%=user1.getInactive_date()%>" maxlength="10">
--%>		
<input type="hidden" name="old_inactive_date" value="<%=user1.getInactive_date()%>"/>
<input type="hidden" name="inactive_date" value="<%=user1.getInactive_date()%>"/>

	</td>
</tr>
<%--
<tr>
	<td>Login Trial</td>
	<td><input type="text" name="login_trial" value="<%=user1.getLogin_trial()%>" maxlength="1"></td>
</tr>
--%>
</table>
<hr>
<p>
	<INPUT type="button" value="Save" onclick="saveWithoutConfirm()">
	<INPUT type="reset" value="Cancel">
	<input type="hidden" name="formAction" value="<%=formAction%>">
</p>
</form>
<%@ include file="../footer.jsp"%>
</body>
</html>

